package com.hncc.dms.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.hncc.dms.domain.DmsDrugModel;
import com.hncc.dms.service.IDmsDrugModelService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import javax.annotation.Resource;

/**
 * 药品模版管理Controller
 * 
 * @author ruoyi
 * @date 2020-08-25
 */
@RestController
@RequestMapping("/dms/drug_model")
@Api(tags = "药品模版管理接口")
public class DmsDrugModelController extends BaseController
{
    @Resource
    private IDmsDrugModelService dmsDrugModelService;

    /**
     * 查询药品模版管理列表
     */
    @ApiOperation(value = "条件分页查询药品模版管理",httpMethod = "GET")
    @PreAuthorize("@ss.hasPermi('dms:drug_model:list')")
    @GetMapping("/list")
    public TableDataInfo list(DmsDrugModel dmsDrugModel)
    {
        startPage();
        List<DmsDrugModel> list = dmsDrugModelService.selectDmsDrugModelList(dmsDrugModel);
        return getDataTable(list);
    }

    /**
     * 导出药品模版管理列表
     */
    @PreAuthorize("@ss.hasPermi('dms:drug_model:export')")
    @Log(title = "药品模版管理", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(DmsDrugModel dmsDrugModel)
    {
        List<DmsDrugModel> list = dmsDrugModelService.selectDmsDrugModelList(dmsDrugModel);
        ExcelUtil<DmsDrugModel> util = new ExcelUtil<DmsDrugModel>(DmsDrugModel.class);
        return util.exportExcel(list, "drug_model");
    }

    /**
     * 获取药品模版管理详细信息
     */
    @ApiOperation(value = "根据id获取药品模版管理详细信息",httpMethod = "GET",
            notes = "根据id查询药品模版管理")
    @ApiImplicitParam(paramType = "path",name = "id",value = "药品模版管理id",dataType = "Long",required = true)
    @PreAuthorize("@ss.hasPermi('dms:drug_model:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(dmsDrugModelService.selectDmiById(id));
    }

    /**
     * 新增药品模版管理
     */
    @ApiOperation(value = "新增",httpMethod = "POST", notes = "新增药品模版管理")
    @ApiImplicitParam(name = "dmsDrugModel", value = "新增药品模版管理", dataType = "DmsDrugModel")
    @PreAuthorize("@ss.hasPermi('dms:drug_model:add')")
    @Log(title = "药品模版管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DmsDrugModel dmsDrugModel) {
        return toAjax(dmsDrugModelService.insertDmsDrugModel(dmsDrugModel));
    }

    /**
     * 修改药品模版管理
     */
    @ApiOperation(value = "修改", httpMethod = "PUT", notes = "修改药品模版管理")
    @ApiImplicitParam(name = "dmsDrugModel", value = "修改药品模版管理", dataType = "DmsDrugModel")
    @PreAuthorize("@ss.hasPermi('dms:drug_model:edit')")
    @Log(title = "药品模版管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DmsDrugModel dmsDrugModel)
    {
        return toAjax(dmsDrugModelService.updateDmsDrugModel(dmsDrugModel));
    }

    /**
     * 删除药品模版管理
     */
    @ApiOperation(value = "批量删除", httpMethod = "DELETE", notes = "根据ids删除药品模版管理")
    @ApiImplicitParam(paramType = "path",name = "ids",value = "药品模版管理id",dataType = "Long[]",required = true)
    @PreAuthorize("@ss.hasPermi('dms:drug_model:remove')")
    @Log(title = "药品模版管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{id}/{type}")
    public AjaxResult remove(@PathVariable Long id,@PathVariable Long type)
    {
        return toAjax(dmsDrugModelService.deleteDmsDrugModelById(id,type));
    }
}
